package com.besttone.action;

import com.besttone.bean.ScsButtonBean;
import com.besttone.model.ScsButton;
import com.besttone.util.JsonUtil;
import com.jfinal.core.Controller;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhengzhenzhen on 2017/7/19.
 * 号码安全:查询前一天的统计数据
 */
public class ScsButtonAction extends Controller {
    private static Log _log = LogFactory.getLog(ScsButtonAction.class);
    public void queryScsButton() {
        String sp_account = getPara("sp_account");
        String sp_pwd = getPara("sp_pwd");
        String day_id=getPara("day_id");
        List<ScsButtonBean> reList=new ArrayList<ScsButtonBean>();
        ScsButtonBean buttonBean=null;
        List<ScsButton> buttonList=ScsButton.dao.getCntsByDay(day_id);
        for(ScsButton button:buttonList){
            buttonBean=new ScsButtonBean();
            buttonBean.setProduct_id(button.getStr("product_id"));
            buttonBean.setProduct_name(button.getStr("product_name"));
            buttonBean.setChannel_no(button.getStr("channel_no"));
            buttonBean.setChannel_name(button.getStr("channel_name"));
            buttonBean.setCnt_uv(button.getInt("cnt_uv"));
            buttonBean.setCnt_pv(button.getInt("cnt_pv"));
            buttonBean.setDay_id(button.getStr("day_id"));
            reList.add(buttonBean);
        }
        String str=JsonUtil.ObjectToJsonString(reList);
        System.out.println(str);
        setAttr("result_msg",str);
        renderJson();
        return;
    }
}
